import logging

import config


class TenderApi:

    def __init__(self, session):
        # 获取session对象
        self.session = session

    # 投资接口
    def tender(self, id, amount, depositCertificate=-1):
        url = config.BASE_HOST + "/trust/trust/tender"
        form_dict = {"id": id, "depositCertificate": depositCertificate, "amount": amount}
        res = self.session.post(url=url, data=form_dict)
        logging.info("投资接口返回的响应体数据：{}".format(res.json()))
        return res

    # 第三方投资接口
    def third_tender(self, url, form_dict):
        res = self.session.post(url=url, data=form_dict)
        logging.info("第三方投资接口返回的响应体数据：{}".format(res.text))
        return res
